#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
	int input = 0;
	while (scanf("%d", &input) == 1)
	{
		for (int i = 0; i < input; i++)
		{
			for (int j = 0; j < input; j++)
			{
				if (i == 0 || i == input - 1 || j == 0 || j == input - 1)
					printf("* ");
				else
					printf("  ");
			}
			printf("\n");
		}
	}

	return 0;
}